package com.zzy.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzy.domain.dto.SupplierPagedto;
import com.zzy.domain.po.Supplier;
import com.zzy.domain.vo.PageResult;
import com.zzy.mapper.SupplierMapper;
import com.zzy.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier> implements SupplierService {
    @Autowired
    private SupplierMapper supplierMapper;
    @Override
    public PageResult<Supplier> getPage(SupplierPagedto supplierPagedto) {
        PageHelper.startPage(supplierPagedto.getPage(),supplierPagedto.getPageSize());
        List<Supplier>list=supplierMapper.page(supplierPagedto);
        Page<Supplier>page= (Page<Supplier>) list;
        return new PageResult<>(page.getTotal(),page.getResult());
    }

//    @Override
//    public List<Supplier> getPage(SupplierPagedto supplierPagedto) {
//        IPage<Supplier>page=new Page<>(supplierPagedto.getPage(),supplierPagedto.getPageSize());
//        LambdaQueryWrapper<Supplier>query=new LambdaQueryWrapper<>();
//        query.like(ObjectUtils.isNotEmpty(supplierPagedto.getSupplierName()),Supplier::getSupplierName,supplierPagedto.getSupplierName());
//        return page(page,query).getRecords();
//    }
}
